package com.lichuang.fruitvarietysm.user.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@Component
public class LocalDateConverterConfig implements Converter<String, LocalDate> {

    @Override
    public LocalDate convert(String source) {
        /**
         * {@link DateTimeFormatter}是jdk8新添加的，线程安全的
         * {@link java.text.SimpleDateFormat}是线程不安全的
         */
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return LocalDate.parse(source);
    }
}
